package com.byxy.entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@Table(name="_supplier")
public class Supplier implements Serializable {
	@Id
	private String id;
	private String name;
	//联系人
	private String contact;
	//联系电话
	private String phone;
	//联系地址
	private String address;
	//传真
	private String fax;
	//描述
	@Column(name="_describe")
	private String describe;
	@OneToMany(mappedBy="supplier")
	private Set<Order> orders=new HashSet<Order>();
	public Supplier() {
		super();
		// TODO Auto-generated constructor stub
	}
	public Supplier(String id, String name, String contact, String phone, String address, String fax, String describe,
			Set<Order> orders) {
		super();
		this.id = id;
		this.name = name;
		this.contact = contact;
		this.phone = phone;
		this.address = address;
		this.fax = fax;
		this.describe = describe;
		this.orders = orders;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getContact() {
		return contact;
	}
	public void setContact(String contact) {
		this.contact = contact;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public String getFax() {
		return fax;
	}
	public void setFax(String fax) {
		this.fax = fax;
	}
	public String getDescribe() {
		return describe;
	}
	public void setDescribe(String describe) {
		this.describe = describe;
	}
	public Set<Order> getOrders() {
		return orders;
	}
	public void setOrders(Set<Order> orders) {
		this.orders = orders;
	}
	@Override
	public String toString() {
		return "Supplier [id=" + id + ", name=" + name + ", contact=" + contact + ", phone=" + phone + ", address="
				+ address + ", fax=" + fax + ", describe=" + describe + ", orders=" + orders + "]";
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Supplier other = (Supplier) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
}
